using System.ComponentModel.DataAnnotations;

namespace ProcessManagementApi.DTOs
{
    /// <summary>
    /// 工艺流程查询条件DTO
    /// </summary>
    public class ProcessFlowQueryDto
    {
        /// <summary>
        /// 工艺流程编号（模糊查询）
        /// </summary>
        public string? ProcessFlowNumber { get; set; }

        /// <summary>
        /// 负责人
        /// </summary>
        public string? ResponsiblePerson { get; set; }

        /// <summary>
        /// 状态（启用/禁用）
        /// </summary>
        public bool? IsActive { get; set; }

        /// <summary>
        /// 所属部门
        /// </summary>
        public string? Department { get; set; }

        /// <summary>
        /// 页码
        /// </summary>
        public int PageIndex { get; set; } = 1;

        /// <summary>
        /// 页面大小
        /// </summary>
        public int PageSize { get; set; } = 10;
    }

    /// <summary>
    /// 工艺流程响应DTO
    /// </summary>
    public class ProcessFlowResponseDto
    {
        /// <summary>
        /// 工艺流程ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 工艺流程编号
        /// </summary>
        public string ProcessFlowNumber { get; set; } = string.Empty;

        /// <summary>
        /// 工艺流程名称
        /// </summary>
        public string ProcessFlowName { get; set; } = string.Empty;

        /// <summary>
        /// 工序数量
        /// </summary>
        public int ProcessCount { get; set; }

        /// <summary>
        /// 负责人
        /// </summary>
        public string? ResponsiblePerson { get; set; }

        /// <summary>
        /// 所属部门
        /// </summary>
        public string? Department { get; set; }

        /// <summary>
        /// 状态（启用/禁用）
        /// </summary>
        public bool IsActive { get; set; }

        /// <summary>
        /// 状态显示文本
        /// </summary>
        public string IsActiveText => IsActive ? "启用" : "禁用";

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }

        /// <summary>
        /// 附件原始文件名
        /// </summary>
        public string? AttachmentOriginalFileName { get; set; }

        /// <summary>
        /// 附件存储文件名
        /// </summary>
        public string? AttachmentStoredFileName { get; set; }

        /// <summary>
        /// 附件文件路径
        /// </summary>
        public string? AttachmentFilePath { get; set; }

        /// <summary>
        /// 附件文件大小（字节）
        /// </summary>
        public long? AttachmentFileSize { get; set; }

        /// <summary>
        /// 附件文件类型
        /// </summary>
        public string? AttachmentContentType { get; set; }

        /// <summary>
        /// 附件备注
        /// </summary>
        public string? AttachmentRemarks { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedTime { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdatedTime { get; set; }

        /// <summary>
        /// 工序步骤列表
        /// </summary>
        public List<ProcessFlowStepDto> ProcessSteps { get; set; } = new List<ProcessFlowStepDto>();
    }

    /// <summary>
    /// 工艺流程步骤DTO
    /// </summary>
    public class ProcessFlowStepDto
    {
        /// <summary>
        /// 步骤ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 步骤序号
        /// </summary>
        public int StepOrder { get; set; }

        /// <summary>
        /// 工序ID
        /// </summary>
        public int ProcessId { get; set; }

        /// <summary>
        /// 工序编号
        /// </summary>
        public string ProcessNumber { get; set; } = string.Empty;

        /// <summary>
        /// 工序名称
        /// </summary>
        public string ProcessName { get; set; } = string.Empty;

        /// <summary>
        /// 工序分类名称
        /// </summary>
        public string ProcessCategoryName { get; set; } = string.Empty;

        /// <summary>
        /// 负责人（优先使用步骤级负责人，其次使用工序级负责人）
        /// </summary>
        public string? ResponsiblePerson { get; set; }

        /// <summary>
        /// 所属部门（优先使用步骤级部门，其次使用工序级部门）
        /// </summary>
        public string? Department { get; set; }

        /// <summary>
        /// 步骤备注
        /// </summary>
        public string? StepRemarks { get; set; }

        /// <summary>
        /// 工序备注
        /// </summary>
        public string? ProcessRemarks { get; set; }
    }

    /// <summary>
    /// 工艺流程创建DTO
    /// </summary>
    public class ProcessFlowCreateDto
    {
        /// <summary>
        /// 工艺流程编号
        /// </summary>
        [Required(ErrorMessage = "工艺流程编号不能为空")]
        [StringLength(50, ErrorMessage = "工艺流程编号长度不能超过50个字符")]
        public string ProcessFlowNumber { get; set; } = string.Empty;

        /// <summary>
        /// 工艺流程名称
        /// </summary>
        [Required(ErrorMessage = "工艺流程名称不能为空")]
        [StringLength(200, ErrorMessage = "工艺流程名称长度不能超过200个字符")]
        public string ProcessFlowName { get; set; } = string.Empty;

        /// <summary>
        /// 工序数量
        /// </summary>
        [Range(0, int.MaxValue, ErrorMessage = "工序数量不能小于0")]
        public int ProcessCount { get; set; }

        /// <summary>
        /// 负责人
        /// </summary>
        [StringLength(50, ErrorMessage = "负责人长度不能超过50个字符")]
        public string? ResponsiblePerson { get; set; }

        /// <summary>
        /// 所属部门
        /// </summary>
        [StringLength(100, ErrorMessage = "所属部门长度不能超过100个字符")]
        public string? Department { get; set; }

        /// <summary>
        /// 状态（启用/禁用）
        /// </summary>
        public bool IsActive { get; set; } = true;

        /// <summary>
        /// 备注
        /// </summary>
        [StringLength(500, ErrorMessage = "备注长度不能超过500个字符")]
        public string? Remarks { get; set; }

        /// <summary>
        /// 附件原始文件名
        /// </summary>
        [StringLength(255, ErrorMessage = "附件原始文件名长度不能超过255个字符")]
        public string? AttachmentOriginalFileName { get; set; }

        /// <summary>
        /// 附件存储文件名
        /// </summary>
        [StringLength(255, ErrorMessage = "附件存储文件名长度不能超过255个字符")]
        public string? AttachmentStoredFileName { get; set; }

        /// <summary>
        /// 附件文件路径
        /// </summary>
        [StringLength(500, ErrorMessage = "附件文件路径长度不能超过500个字符")]
        public string? AttachmentFilePath { get; set; }

        /// <summary>
        /// 附件文件大小（字节）
        /// </summary>
        public long? AttachmentFileSize { get; set; }

        /// <summary>
        /// 附件文件类型
        /// </summary>
        [StringLength(100, ErrorMessage = "附件文件类型长度不能超过100个字符")]
        public string? AttachmentContentType { get; set; }

        /// <summary>
        /// 附件备注
        /// </summary>
        [StringLength(500, ErrorMessage = "附件备注长度不能超过500个字符")]
        public string? AttachmentRemarks { get; set; }
    }

    /// <summary>
    /// 工艺流程更新DTO
    /// </summary>
    public class ProcessFlowUpdateDto
    {
        /// <summary>
        /// 工艺流程ID
        /// </summary>
        [Required(ErrorMessage = "工艺流程ID不能为空")]
        public int Id { get; set; }

        /// <summary>
        /// 工艺流程编号
        /// </summary>
        [Required(ErrorMessage = "工艺流程编号不能为空")]
        [StringLength(50, ErrorMessage = "工艺流程编号长度不能超过50个字符")]
        public string ProcessFlowNumber { get; set; } = string.Empty;

        /// <summary>
        /// 工艺流程名称
        /// </summary>
        [Required(ErrorMessage = "工艺流程名称不能为空")]
        [StringLength(200, ErrorMessage = "工艺流程名称长度不能超过200个字符")]
        public string ProcessFlowName { get; set; } = string.Empty;

        /// <summary>
        /// 工序数量
        /// </summary>
        [Range(0, int.MaxValue, ErrorMessage = "工序数量不能小于0")]
        public int ProcessCount { get; set; }

        /// <summary>
        /// 负责人
        /// </summary>
        [StringLength(50, ErrorMessage = "负责人长度不能超过50个字符")]
        public string? ResponsiblePerson { get; set; }

        /// <summary>
        /// 所属部门
        /// </summary>
        [StringLength(100, ErrorMessage = "所属部门长度不能超过100个字符")]
        public string? Department { get; set; }

        /// <summary>
        /// 状态（启用/禁用）
        /// </summary>
        public bool IsActive { get; set; } = true;

        /// <summary>
        /// 备注
        /// </summary>
        [StringLength(500, ErrorMessage = "备注长度不能超过500个字符")]
        public string? Remarks { get; set; }

        /// <summary>
        /// 附件原始文件名
        /// </summary>
        [StringLength(255, ErrorMessage = "附件原始文件名长度不能超过255个字符")]
        public string? AttachmentOriginalFileName { get; set; }

        /// <summary>
        /// 附件存储文件名
        /// </summary>
        [StringLength(255, ErrorMessage = "附件存储文件名长度不能超过255个字符")]
        public string? AttachmentStoredFileName { get; set; }

        /// <summary>
        /// 附件文件路径
        /// </summary>
        [StringLength(500, ErrorMessage = "附件文件路径长度不能超过500个字符")]
        public string? AttachmentFilePath { get; set; }

        /// <summary>
        /// 附件文件大小（字节）
        /// </summary>
        public long? AttachmentFileSize { get; set; }

        /// <summary>
        /// 附件文件类型
        /// </summary>
        [StringLength(100, ErrorMessage = "附件文件类型长度不能超过100个字符")]
        public string? AttachmentContentType { get; set; }

        /// <summary>
        /// 附件备注
        /// </summary>
        [StringLength(500, ErrorMessage = "附件备注长度不能超过500个字符")]
        public string? AttachmentRemarks { get; set; }
    }

    /// <summary>
    /// 工艺流程步骤导出查询DTO
    /// </summary>
    public class ProcessFlowStepExportQueryDto
    {
        /// <summary>
        /// 工艺流程ID
        /// </summary>
        public int ProcessFlowId { get; set; }

        /// <summary>
        /// 工序编号或名称（可选筛选）
        /// </summary>
        public string? ProcessNumberOrName { get; set; }

        /// <summary>
        /// 负责人（可选筛选）
        /// </summary>
        public string? ResponsiblePerson { get; set; }

        /// <summary>
        /// 部门（可选筛选）
        /// </summary>
        public string? Department { get; set; }

        /// <summary>
        /// 工序分类名称（可选筛选）
        /// </summary>
        public string? ProcessCategoryName { get; set; }
    }
} 